package com.lanproperiesinternal.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author kezhihui
 * @date 2022/05/20
 */
@ControllerAdvice
@Slf4j
public class GlobalException {

    @ExceptionHandler(Exception.class)
    public ModelAndView toError(HttpServletRequest request, Exception e) throws Exception{
        log.error("系统出错,详情:{}",e.getMessage());
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("./error");
        return  modelAndView;
    }
}
